package com.zhou.controller;

import com.alibaba.fastjson.JSON;
import com.zhou.bean.Express;
import com.zhou.bean.Message;
import com.zhou.mvc.ResponseBody;
import com.zhou.service.ExpressService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CheckAllController {
    @ResponseBody("/checknumber.do")
    public String checkNumber (HttpServletRequest req, HttpServletResponse resp){
        String number = req.getParameter("number");
        Express byNumber = ExpressService.findByNumber(number);
        Message message = new Message();
        if (byNumber.getNumber()==null){
            message.setStatus(0);
            message.setResult("订单号可用");
        }else {
            message.setStatus(0);
            message.setResult("订单号重复，请重新输入");
        }
        return JSON.toJSONString(message);
    }
}
